package com.ayoka.ui.course.detail;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.ayoka.R;
import com.ayoka.bean.CourseBean;
import com.jcp.baselibrary.dialog.BaseDialogBuilder;
import com.jcp.baselibrary.dialog.BaseDialogFragment;

/**
 * Created by jinchunping on 2019/1/23.
 */

public class CourseDetailTextDialog extends BaseDialogFragment {

    public static CourseDetailTextDialog newInstance(Builder builder) {
        CourseDetailTextDialog dialog = new CourseDetailTextDialog();
        Bundle bundle = getArgumentBundle(builder);
        bundle.putSerializable("CourseBean", builder.courseBean);
        dialog.setArguments(bundle);
        return dialog;
    }

    @Override
    protected void convertView(@Nullable View container, final BaseDialogFragment dialogFragment) {
        container.findViewById(R.id.iv_close).setOnClickListener(new onCloseClickListener());
        if (getArguments() != null) {
            CourseBean courseBean = (CourseBean) getArguments().getSerializable("CourseBean");
            TextView tvCourseTitle = container.findViewById(R.id.tv_course_title);
            tvCourseTitle.setText(courseBean.Title);
            TextView tvCourseSubTitle = container.findViewById(R.id.tv_course_sub_title);
            tvCourseSubTitle.setText(courseBean.SubTitle);
            TextView tvCourseContent = container.findViewById(R.id.tv_course_content);
            tvCourseContent.setText(courseBean.Descp);
        }
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_course_detail_text;
    }


    public static class Builder extends BaseDialogBuilder<Builder, CourseDetailTextDialog> {

        private CourseBean courseBean;


        public Builder setCourseBean(CourseBean courseBean) {
            this.courseBean = courseBean;
            return this;
        }

        @Override
        public CourseDetailTextDialog build() {
            return CourseDetailTextDialog.newInstance(this);
        }
    }
}